package net.hn.hnms.biz.equipment.group.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.hn.hnms.biz.equipment.group.domain.MineALlSwitchVo;
import net.hn.hnms.biz.equipment.group.server.GroupServer;
import net.hn.hnms.sys.common.core.constant.Constants;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.redis.domain.SysOrganizationVo;
import net.hn.hnms.sys.common.redis.utils.RedisUtils;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 智呈物联 pan'sx
 * 2022/8/22 11:51
 * 1.0 version
 */
@Api(value = "集团端-生产管控-重大设备", tags = {"集团端-生产管控-重大设备"})
@RestController
@RequestMapping("group/production/equipment")
public class EquipmentGroupController {
    @Resource
    private GroupServer groupServer;

    @GetMapping("operationRate")
    @ApiOperation("生产看板-本月开机率台账")
    public R<Map> operationRate(@ApiParam(value = "公司编码") String companyCode,
                                @ApiParam(value = "月份：yyyy-MM")@DateTimeFormat(pattern = "yyyy-MM") Date month){
        Map map = groupServer.operationRate(companyCode,month);
        return R.ok(map);
    }

    @GetMapping("getMineInfo")
    @ApiOperation("根据编码获取煤矿信息")
    public R<SysOrganizationVo> getMineinfo(@ApiParam(value = "编码,默认为零", defaultValue = "0") String code) {
        //获取词典信息
        SysOrganizationVo sysOrganizationVo=RedisUtils.getCacheObject(Constants.SYS_CODESUB_KEY + code);
        return R.ok(sysOrganizationVo);
    }

    @GetMapping("getAllMineSwitch")
    @ApiOperation("获取所有煤矿重大设备开关信息")
    public R<List<MineALlSwitchVo>> getAllMineSwitch(@ApiParam(value = "公司编码，不传默认查询所有煤矿") String companyCode){
        List<MineALlSwitchVo> mineALlSwitchVos = groupServer.getAllMineSwitch(companyCode);
        return R.ok(mineALlSwitchVos);
    }
}
